package com.wsx.first.c;

import java.util.Scanner;

/**
 * @author: wangshunxi
 * @date: 2022/5/10 16:22
 * @Description:
 */
public class Main0001 {
    public static void main(String[] args) {
        try (Scanner scanner = new Scanner(System.in)) {
            String content = scanner.nextLine();
            solution(content);
        }
    }

    private static void solution(String content) {
        String[] split = null;
        if (content == null) {
            System.out.println(-1);
        } else if (content.length() == 0) {
            System.out.println(0);
        } else if (content.length() >= 5000) {
            System.out.println(-2);
        } else if (content.endsWith(" ")) {
            System.out.println(-3);
        } else {
            split = content.split(" ");
            System.out.println(split[split.length - 1].length());
        }



    }
}
